package com.guigu.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guigu.pojo.Roles;
import com.guigu.service.RolesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.management.relation.Role;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class RolesController {

    @Autowired
    RolesService rolesService;

    //查询所有角色
    @RequestMapping("queryallroles.action")
    public List<Roles> queryallroles(){

        return rolesService.list();
    }

    //分页显示所有角色
    @RequestMapping("showallroles.action")
    public Page<Roles> showallroles(@RequestParam(value = "pageno",defaultValue = "1")Integer pageno,
                                    @RequestParam(value = "pagesize",defaultValue = "5")Integer pagesize,
                                    Roles roles){

        return rolesService.showallroles(pageno,pagesize,roles);
    }

    //修改状态
    @RequestMapping("eidebystate.action")
    public Map eidebystate(Roles roles){

        System.out.println(roles);
        return rolesService.eidebystate(roles);
    }

    //添加
    @RequestMapping("addroles.action")
    public Map addroles(Roles roles){

        return rolesService.addroles(roles);
    }

    //根据id查找数据
    @RequestMapping("querybyid_roles.action")
    public Roles querybyid_roles(Roles roles){

        return rolesService.querybyid_roles(roles);
    }

    //修改角色
    @RequestMapping("eiderole.action")
    public Map eiderole(Roles roles){

        return rolesService.eiderole(roles);
    }
}
